/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package simple.utils.pool;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import simple.utils.httpclient.HTTPClient;

import java.io.IOException;

/**
 *
 * @author rehak
 */
public class HTTPClientPool extends Pool<HTTPClient> {

    private static final Logger LOGGER = LoggerFactory.getLogger(HTTPClientPool.class);
    private String host;
    private int port;
    private boolean ssl;

    public HTTPClientPool(String host, int port, boolean ssl) {
        super();
        this.host = host;
        this.port = port;
        this.ssl = ssl;
    }

    @Override
    protected HTTPClient createInstance() {
        return new HTTPClient(host, port, ssl);
    }

    @Override
    protected void destroy(HTTPClient instance) {
        super.destroy(instance);
        if (instance != null) {
            try {
                instance.close();
            } catch (IOException ex) {
                LOGGER.error("Error closing HTTPClient", ex);
            }
        }
    }
}
